import Mock from 'mockjs';
import actorJson from '../../data/media/actor.json';

export default {
    className: "Media.Model.Actor",
    queryData: function(postData) {

        return {
            isSuccess: "Y",
            reason: "",
            message: [],
            data: {
                recordCount: actorJson.length,
                pageCount: 1,
                pageIndex: 1,
                pageSize: 20,
                queryResult: actorJson
            }
        };

    },
    queryByKeyID: function(postData) {
        console.log(postData);
        var curFindObject = null;
        for (var i = 0; i < actorJson.length; i++) {
            if (postData.keyID == actorJson[i].keyID) {
                curFindObject = actorJson[i];
                break;
            }
        }
        if (curFindObject == null) {
            return Mock.mock({
                isSuccess: "Y",
                reason: "",
                message: [],
                "data": {
                    "keyID|1000-9999": 1000,
                    "name": Mock.mock('@ctitle'), //@title为英文版
                    "identifier": /^[0-9][0-9][0-9][0-9][0-9][0-9]$/, //标识符
                    "byName": Mock.mock('@ctitle'),
                    "profession": "导演",
                    "sex": "女",
                    "nationality": Mock.mock('@ctitle'),
                    "status": "审核通过",
                    "version": 1,
                    "constellation": "白羊座",
                    "bloodType": "AB",
                }
            });
        } else {
            return {
                isSuccess: "Y",
                reason: "",
                message: [],
                data: curFindObject,
            };
        }
    },
};
